Skip to content

tests: cover more exported_private_dependencies cases #144082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mladedav
Copy link
Contributor

@mladedav mladedav commented Jul 17, 2025

This PR adds tests for all missing cases from #71043 and some on top of that. I believe with this, that issue can be closed.

Some of the lints can be improved, e.g. provided_impl_trait and impl From<PublicWithStdImpl> for OtherType lint twice.

cc @epage in case you want to double check I didn't miss anything.

@rustbot
Copy link
Collaborator

rustbot commented Jul 17, 2025

r? @petrochenkov

rustbot has assigned @petrochenkov.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 17, 2025
pub OtherType,
//~^ ERROR type `OtherType` from private dependency 'priv_dep' in public interface [exported_private_dependencies]
OtherType,
PubType,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for symmetry with the struct, should this field be pub?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, fixed.

@mladedav mladedav force-pushed the dm/pub-priv-tests branch from f8cf216 to 2390abe Compare July 18, 2025 08:20
@mladedav
Copy link
Contributor Author

This would conflict with #144098 which will most likely break the tests of RPITIT again.

So I'll convert this to a draft so that this doesn't add work there if it's merged first and once that is merged, I'll update this.

It might also mean that the parent issue will still have to be kept open even after mergint this since the current fix in the linked PR breaks linting about using traits from private dependencies again.

@mladedav mladedav marked this pull request as draft July 18, 2025 08:37
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 18, 2025
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

+ error[E0449]: visibility qualifiers are not permitted here
+   --> $DIR/pub-priv1.rs:49:9
+    |
+ LL |         pub other_field: PubType,
+    |         ^^^ help: remove the qualifier
+    |
+    = note: enum variants and their fields always share the visibility of the enum they are in
+ 
1 error: crate `priv_dep` from private dependency 'priv_dep' is re-exported
2   --> $DIR/pub-priv1.rs:12:1
3    |

64 LL | pub use priv_dep::OtherType as Renamed;
65    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:29:5
-    |
- LL |     pub field: OtherType,
-    |     ^^^^^^^^^^^^^^^^^^^^
+ error: aborting due to 11 previous errors
72 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:36:5
-    |
- LL |     pub OtherType,
-    |     ^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:44:21
-    |
- LL |     ActualOtherType(OtherType, PubType),
-    |                     ^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:47:9
-    |
- LL |         field: OtherType,
-    |         ^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:54:1
-    |
- LL | pub type ReexportedPublicGeneric = PublicGenericType<OtherType, ()>;
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:56:1
-    |
- LL | pub type ReexportedPrivateGeneric = PublicGenericType<(), OtherType>;
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:59:1
-    |
- LL | pub struct PublicGenericBoundedType<T: OtherTrait>(T);
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:63:5
-    |
- LL |     pub fn pub_fn_param(param: OtherType) {}
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:66:5
-    |
- LL |     pub fn pub_fn_return() -> OtherType { OtherType }
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:73:5
-    |
- LL |     type Foo: OtherTrait;
-    |     ^^^^^^^^^^^^^^^^^^^^
- 
- error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:76:33
-    |
- LL |     fn required_impl_trait() -> impl OtherTrait;
-    |                                 ^^^^^^^^^^^^^^^
- 
- error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:79:33
-    |
- LL |     fn provided_impl_trait() -> impl OtherTrait { OtherType }
-    |                                 ^^^^^^^^^^^^^^^
- 
- error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:79:33
-    |
- LL |     fn provided_impl_trait() -> impl OtherTrait { OtherType }
-    |                                 ^^^^^^^^^^^^^^^
-    |
-    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:83:5
-    |
- LL |     fn required_concrete() -> OtherType;
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:86:5
-    |
- LL |     fn provided_concrete() -> OtherType { OtherType }
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:90:1
-    |
- LL | pub trait WithSuperTrait: OtherTrait {}
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:99:5
-    |
- LL |     type X = OtherType;
-    |     ^^^^^^
- 
- error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:103:1
-    |
- LL | pub fn in_bounds<T: OtherTrait>(x: T) { unimplemented!() }
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:106:1
-    |
- LL | pub fn private_return_impl_trait() -> impl OtherTrait { OtherType }
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:109:1
-    |
- LL | pub fn private_return() -> OtherType { OtherType }
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:112:1
-    |
- LL | pub fn private_in_generic() -> std::num::Saturating<OtherType> { unimplemented!() }
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:115:1
-    |
- LL | pub static STATIC: OtherType = OtherType;
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:118:1
-    |
- LL | pub const CONST: OtherType = OtherType;
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:121:1
-    |
- LL | pub type Alias = OtherType;
-    | ^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:124:1
-    |
- LL | pub type AliasOfAlias = priv_dep::PubPub;
-    | ^^^^^^^^^^^^^^^^^^^^^
- 
- error: trait `OtherTrait` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:129:1
-    |
- LL | impl OtherTrait for PublicWithPrivateImpl {}
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:134:1
-    |
- LL | impl PubTraitOnPrivate for OtherType {}
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:134:1
-    |
- LL | impl PubTraitOnPrivate for OtherType {}
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-    |
-    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:140:1
-    |
- LL | impl From<OtherType> for PublicWithStdImpl {
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:142:5
-    |
- LL |     fn from(val: OtherType) -> Self { Self }
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:146:1
-    |
- LL | impl From<PublicWithStdImpl> for OtherType {
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:146:1
-    |
- LL | impl From<PublicWithStdImpl> for OtherType {
-    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-    |
-    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:149:5
-    |
- LL |     fn from(val: PublicWithStdImpl) -> Self { Self }
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- 
- error: type `OtherType` from private dependency 'priv_dep' in public interface
-   --> $DIR/pub-priv1.rs:149:5
-    |
- LL |     fn from(val: PublicWithStdImpl) -> Self { Self }
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-    |
-    = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
- 
- error: aborting due to 44 previous errors
- 
+ For more information about this error, try `rustc --explain E0449`.
281 

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:49:9
+ error[E0449]: visibility qualifiers are not permitted here
+   --> $DIR/pub-priv1.rs:49:9
+    |
+ LL |         pub other_field: PubType,
+    |         ^^^ help: remove the qualifier
+    |
+    = note: enum variants and their fields always share the visibility of the enum they are in
+ 
+ error: aborting due to 11 previous errors
+ For more information about this error, try `rustc --explain E0449`.
---
To only update this specific test, also pass `--test-args privacy/pub-priv-dep/pub-priv1.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/privacy/pub-priv-dep/pub-priv1" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/privacy/pub-priv-dep/pub-priv1/auxiliary" "-Zunstable-options" "--extern" "priv:priv_dep=/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/privacy/pub-priv-dep/pub-priv1/auxiliary/libpriv_dep.so" "--extern" "priv:pm=/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/privacy/pub-priv-dep/pub-priv1/auxiliary/libpm.so"
stdout: none
--- stderr -------------------------------
error[E0449]: visibility qualifiers are not permitted here
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:49:9
   |
LL |         pub other_field: PubType,
   |         ^^^ help: remove the qualifier
   |
   = note: enum variants and their fields always share the visibility of the enum they are in

error: crate `priv_dep` from private dependency 'priv_dep' is re-exported
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:12:1
   |
LL | pub extern crate priv_dep;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:9:9
   |
LL | #![deny(exported_private_dependencies)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: macro `m` from private dependency 'priv_dep' is re-exported
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:159:9
   |
LL | pub use priv_dep::m;
   |         ^^^^^^^^^^^

error: macro `fn_like` from private dependency 'pm' is re-exported
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:161:9
   |
LL | pub use pm::fn_like;
   |         ^^^^^^^^^^^

error: derive macro `PmDerive` from private dependency 'pm' is re-exported
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:163:9
   |
LL | pub use pm::PmDerive;
   |         ^^^^^^^^^^^^

error: attribute macro `pm_attr` from private dependency 'pm' is re-exported
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:165:9
   |
LL | pub use pm::pm_attr;
   |         ^^^^^^^^^^^

error: variant `V1` from private dependency 'priv_dep' is re-exported
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:168:9
   |
LL | pub use priv_dep::E::V1;
   |         ^^^^^^^^^^^^^^^

error: type alias `Unit` from private dependency 'priv_dep' is re-exported
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:171:9
   |
LL | pub use priv_dep::Unit;
   |         ^^^^^^^^^^^^^^

error: type alias `PubPub` from private dependency 'priv_dep' is re-exported
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:173:9
   |
LL | pub use priv_dep::PubPub;
   |         ^^^^^^^^^^^^^^^^

error: type alias `PubPriv` from private dependency 'priv_dep' is re-exported
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:175:9
   |
LL | pub use priv_dep::PubPriv;
   |         ^^^^^^^^^^^^^^^^^

error: struct `Renamed` from private dependency 'priv_dep' is re-exported
##[error]  --> /checkout/tests/ui/privacy/pub-priv-dep/pub-priv1.rs:177:9
   |
LL | pub use priv_dep::OtherType as Renamed;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants